package com.mba.webservice;

import org.json.JSONException;
import org.json.JSONObject;

import com.mba.bean.MBAParameters;
import com.mba.net.AsyncWebRunner;

/**
 * 消息 API的基类，每个接口类都继承了此抽象类
 * @author Jacob
 *
 */
public class MbaAPI {
	
	/**
     * 访问微博服务接口的地址
     */
	public static final String API_SERVER = "https://api.weibo.com/2";
	/**
	 * post请求方式
	 */
	public static final String HTTPMETHOD_POST = "POST";
	/**
	 * get请求方式
	 */
	public static final String HTTPMETHOD_GET = "GET";
	
	
	/**
	 * 构造函数，使用各个API接口提供的服务前必须先获取Token
	 * @param accesssToken 
	 */
	public MbaAPI(){
	   
	}
	
	protected String request( final String url, final MBAParameters params,
			final String httpMethod) {
		params.add("access_token", "token");
		return AsyncWebRunner.request(url, params, httpMethod);
	}
	
	
	
    public JSONObject toJSONObject(String str) throws Exception {
        try {
            return(new JSONObject(str));
        } catch (JSONException jsone) {
            throw new Exception(jsone);
        }
    }
	
	
	
	

}
